home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / source / blt / dvablt.asm < prev    next >
Encoding:
Assembly Source File  |  1993-09-05  |  6.1 KB  |  232 lines

  1.         .xlist
  2.         include cmacro32.inc
  3.         include windows.inc
  4.         .list
  5.  
  6. ?PLM=1
  7. ?WIN=0
  8.  
  9. ifndef SEGNAME
  10.     SEGNAME equ <_TEXT32>
  11. endif
  12.  
  13. createSeg %SEGNAME, CodeSeg, word, public, CODE
  14.  
  15. sBegin  CodeSeg
  16.         .386
  17.         assumes cs,CodeSeg
  18.         assumes ds,nothing
  19.         assumes es,nothing
  20.  
  21. ;-----------------------------------------------------------------------;
  22. ;   dib_xy bpp, x, y
  23. ;
  24. ;   Entry:
  25. ;       esi     --> BITMAPINFO
  26. ;       edi     --> BITS
  27. ;   Exit:
  28. ;       esi     --> BITMAPINFO
  29. ;       edi     --> BITS (x,y)
  30. ;       ecx     -- next_scan
  31. ;
  32. ;   NOTE:
  33. ;       biSizeImage *must* be right
  34. ;-----------------------------------------------------------------------;
  35.  
  36. dib_xy  macro   dib_x, dib_y, dib_bpp
  37.         LOCAL   l1
  38.  
  39.         mov     ebx,dib_x
  40.         mov     ecx,[esi].biWidth           ; get width pixels
  41.  
  42. ifb <dib_bpp>
  43.         movzx   eax,[esi].biBitCount
  44.         shr     eax,3
  45.         xchg    ebx,eax
  46.         mul     ebx
  47.         xchg    ebx,eax
  48.         mul     ecx
  49.         mov     ecx,eax
  50. elseif (dib_bpp eq 8)
  51.         ; nothing
  52. elseif (dib_bpp eq 16)
  53.         add     ebx,ebx
  54.         add     ecx,ecx                     ; convert to width bytes
  55. elseif (dib_bpp eq 24)
  56.         lea     ebx,[ebx + 2*ebx]
  57.         lea     ecx,[ecx + 2*ecx]           ; convert to width bytes
  58. elseif (dib_bpp eq 32)
  59.         lea     ebx,[4*ebx]
  60.         lea     ecx,[4*ecx]                 ; convert to width bytes
  61. else
  62.         ack
  63. endif
  64.         add     ecx,3                       ; round up to dword
  65.         and     cl,not 3
  66.  
  67.         add     edi,ebx                     ; add in x offset
  68.         mov     edx,[esi].biHeight          ; get height
  69.         or      edx,edx                     ; if < 0 then it is a
  70.         jge     short l1                    ; top to bottom dib
  71.  
  72.         neg     ecx                         ; WidthBytes = -WidthBytes
  73.         add     edi,[esi].biSizeImage       ; point edi to "first" scan
  74.         add     edi,ecx
  75. l1:
  76.         ; ecx = next_scan, eax = y
  77.         mov     eax,dib_y
  78.         imul    ecx                         ; eax = y * next_scan
  79.         add     edi,eax                     ; edi -> (x,y)
  80. endm
  81.  
  82. ;--------------------------Private-Routine-------------------------------;
  83. ; DVABlt
  84. ;
  85. ; draws a solid rect
  86. ;
  87. ; Entry:
  88. ;       lpBits          bits pointer
  89. ;       width_bytes     width in bytes to next scan
  90. ;       lpPoints        points to draw.
  91. ; Return:
  92. ;       none
  93. ; Error Returns:
  94. ;       none
  95. ; Registers Preserved:
  96. ;       none
  97. ; Registers Destroyed:
  98. ;       AX,BX,CX,DX,DS,ES,SI,DI,FLAGS
  99. ; Calls:
  100. ;       non
  101. ; History:
  102. ;       Mon 26-Mar-1990 -by-  Todd Laney [ToddLa]
  103. ;-----------------------------------------------------------------------;
  104.         assumes ds,nothing
  105.         assumes es,nothing
  106.  
  107. DVABltLoopStart label word
  108.         dd      DVABltStart0
  109.         dd      DVABltStart1
  110.         dd      DVABltStart2
  111.         dd      DVABltStart3
  112.  
  113. cProc   DVABlt,<FAR,PUBLIC,PASCAL>,<ds>
  114.         parmD   biDst
  115.         parmD   lpDst
  116.         parmD   DstX
  117.         parmD   DstY
  118.         parmD   DstDX
  119.         parmD   DstDY
  120.         parmD   biSrc
  121.         parmD   lpSrc
  122.         parmD   SrcX
  123.         parmD   SrcY
  124.  
  125.         localD  src_next_scan
  126.         localD  dst_next_scan
  127. cBegin
  128.         push    edi
  129.         push    esi
  130.  
  131.         xor     esi,esi
  132.  
  133.         and     DstDX, not 3
  134.         jz      DVABltExit
  135.  
  136.         lds     si,biSrc                ; ds:esi --> bitmapinfo
  137.         movzx   edi,word ptr lpSrc[0]   ; edi --> bits
  138.         dib_xy  SrcX, SrcY
  139.         mov     src_next_scan, ecx
  140.         push    edi
  141.  
  142.         xor     edi,edi
  143.         lds     si,biDst                ; ds:esi --> bitmapinfo
  144.         les     di,lpDst                ; edi --> bits
  145.         dib_xy  DstX, DstY
  146.         mov     dst_next_scan, ecx
  147.  
  148.         pop     esi                     ; ds:esi --> source.
  149.         mov     ds,word ptr lpSrc[2]
  150.  
  151.         mov     ecx, DstDX
  152.         sub     src_next_scan,ecx
  153.         sub     dst_next_scan,ecx
  154.  
  155.         mov     ebx,DstX
  156.         and     ebx,011b
  157.         jmp     DVABltLoopStart[ebx*4]
  158.  
  159. DVABltStart0:
  160.         mov     ecx,DstDX
  161.         shr     ecx,2
  162.         mov     DstDX,ecx
  163. DVABltLoop0:
  164.         mov     ecx,DstDX
  165.         rep     movs dword ptr es:[edi], dword ptr ds:[esi]
  166.         add     edi,dst_next_scan
  167.         add     esi,src_next_scan
  168.         dec     DstDY
  169.         jnz     short DVABltLoop0
  170.         jz      DVABltExit
  171.  
  172. DVABltStart1:
  173.         mov     ecx,DstDX
  174.         sub     ecx,3
  175.         shr     ecx,2
  176.         mov     DstDX,ecx
  177. DVABltLoop1:
  178.         mov     ecx,DstDX
  179.                 movs byte  ptr es:[edi], byte  ptr ds:[esi]
  180.                 movs word  ptr es:[edi], word  ptr ds:[esi]
  181.         rep     movs dword ptr es:[edi], dword ptr ds:[esi]
  182.                 movs byte  ptr es:[edi], byte  ptr ds:[esi]
  183.         add     edi,dst_next_scan
  184.         add     esi,src_next_scan
  185.         dec     DstDY
  186.         jnz     short DVABltLoop1
  187.  
  188.         jz      DVABltExit
  189.  
  190. DVABltStart2:
  191.         mov     ecx,DstDX
  192.         sub     ecx,2
  193.         shr     ecx,2
  194.         mov     DstDX,ecx
  195. DVABltLoop2:
  196.         mov     ecx,DstDX
  197.                 movs word  ptr es:[edi], word  ptr ds:[esi]
  198.         rep     movs dword ptr es:[edi], dword ptr ds:[esi]
  199.                 movs word  ptr es:[edi], word  ptr ds:[esi]
  200.         add     edi,dst_next_scan
  201.         add     esi,src_next_scan
  202.         dec     DstDY
  203.         jnz     short DVABltLoop2
  204.  
  205.         jz      DVABltExit
  206.  
  207. DVABltStart3:
  208.         mov     ecx,DstDX
  209.         sub     ecx,1
  210.         shr     ecx,2
  211.         mov     DstDX,ecx
  212. DVABltLoop3:
  213.         mov     ecx,DstDX
  214.                 movs byte  ptr es:[edi], byte  ptr ds:[esi]
  215.         rep     movs dword ptr es:[edi], dword ptr ds:[esi]
  216.                 movs word  ptr es:[edi], word  ptr ds:[esi]
  217.                 movs byte  ptr es:[edi], byte  ptr ds:[esi]
  218.         add     edi,dst_next_scan
  219.         add     esi,src_next_scan
  220.         dec     DstDY
  221.         jnz     short DVABltLoop3
  222.         jz      DVABltExit
  223.  
  224. DVABltExit:
  225.         pop    esi
  226.         pop    edi
  227. cEnd
  228.  
  229.  
  230. sEnd
  231. end
  232.